package com.yh.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yh.entity.User;
import com.yh.mapper.UserMapper;
import com.yh.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yh
 * @since 2021-05-10
 */
@Service
@AllArgsConstructor
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
    private UserMapper userMapper;
    @Override
    public Page<User> getPageUser(Integer pageNum, Integer pageSize) {
        Page<User> userPage = userMapper.selectPage(new Page<>(pageNum, pageSize), new LambdaQueryWrapper<>());
        return userPage;
    }

    @Override
    public User saveUser(User user) {
        userMapper.insert(user);
        return user;
    }

    @Override
    public User updateUser(User user) {
        userMapper.updateById(user);
        return user;
    }

    @Override
    public User getInfo(String id) {
        return userMapper.selectById(id);
    }
}
